#include <iostream>
#include <string>
#include <list>

class CWordFreq
{
public:
    CWordFreq(const char* szword):m_strword(szword),m_freq(1){}
    CWordFreq(const std::string& strword):m_strword(strword),m_freq(1){}
    void Increment(){m_freq++;}
    friend bool operator == (const CWordFreq& lhs, const CWordFreq& rhs){return lhs.m_strword == rhs.m_strword;}
    friend bool operator < (const CWordFreq& lhs, const CWordFreq& rhs){return lhs.m_strword < rhs.m_strword;}
    friend std::ostream& operator << (std::ostream &ostr, const CWordFreq& w){ostr<<w.m_strword<<"("<<w.m_freq<<")\n"; return ostr;}//友元函数，非类成员函数
    static std::list<CWordFreq>::iterator SeqSearch(std::list<CWordFreq>::iterator begin, std::list<CWordFreq>::iterator end, CWordFreq wf)
    {
        std::list<CWordFreq>::iterator cit = begin;
        while (cit != end)
        {
            if ((*cit) == wf)
            {
                return cit;
            }
            cit++;
        }
        return end;
    }
private:
    std::string m_strword;
    int m_freq;
};